Repository navigation
Split the project upload and update handlers into named steps - #72
Merged
Merged
Conversation
Exercise plain, sparse, workspace, delta, restore, branch merge, pull merge and history replacement uploads, their failure paths, and the project update fields and refusals. A fake Rotur answers profile lookups so team changes and transfers run offline, and the run ends with each stored project record and a blob inventory.
handleUploadProjectLocked and handleUpdateProjectLocked now read as a sequence of small steps that each return a Refusal record, so every early return keeps its status, body and order. Upload state moves through UploadRequest, UploadHistory, UploadArchive and UploadRollback records; update state through OwnerTransfer. Pure decisions live in policy files with tests, and the request, refusal and editor scope helpers are shared by both handlers.
refused() turned any status other than 400, 403 and 404 into a 500. Give 500 its own branch and send any other status as it is, with an ok: false body. No current refusal uses another status, so responses are unchanged.
Every source file lists its exports after its imports; project-update.osl had none. Its OwnerTransfer record moves to project-update-policy.osl, next to how the upload step records sit in project-upload-policy.osl.
project-upload-policy.osl was collecting helpers that are not upload policy. keysNotIn, storedWorkspaceLayers, replacedWorkspaceKeys and projectFilesErrorBody move to project-upload-publish.osl, and megabytes with the three size failure helpers move to project-upload-files.osl. Their tests move into new test files beside those sources.
The split carried three comments over unchanged. New code here has no comments, and the function and parameter names already say what they described.
The smoke test masked far more than was volatile. Its key pattern was case-insensitive, so suffix rules also hid dataFormat, allowedItems, item and product ids, credit URLs, jsonKey and workspaceKey, and sizes were rounded to KiB, which would hide a character count used as a byte count. Mask only named volatile keys (tokens, view keys, timestamps, history sizes, notification ids and the history-sized quota figures), random access keys in URLs and embedded hashes and times. Sizes are compared exactly, and staged chunk sizes are checked against the bytes sent. Every successful upload and update now records the stored project, and the blob inventory lists the exact asset and project JSON names. A non-ASCII project and description tell characters from bytes.
Add the refusals that can be reached offline: a corrupt sb3 that only fails to decompress, an oversized asset (project_too_large), a full Rotur storage (storage_full, from a fake storage ledger that refuses one user), a missing worktree asset, history that does not descend from the saved head, a merge tree that cannot be merged, and a pull whose source remix was deleted. Three more steps make a data directory read-only for one request to reach the failure paths after the files are accepted: storing extension sources, storing the project JSON and saving the project record. They answer 500 by design, so they are listed as expected errors. checkGeneratedHistory cannot be reached offline: merge and restore archives are built to match the stored history they are checked against.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two largest request handlers each did everything inline.
handleUploadProjectLocked(565 lines) andhandleUpdateProjectLocked(485) are now short lists of named steps, 63 and 45 lines. No behaviour changes.Each step that can refuse returns a
Refusal, so every early exit keeps its status, body and order. State between steps goes through small records rather than shared locals.Smoke test:
scripts/e2e_smoke.pygrew from 28 to over 200 steps.Verification
osl test(51 pass),osl lsp checkandcheck_conventionspass.The same work found pre-existing bugs in these paths, including locks that stay held after a thrown error. They are fixed separately in a stacked follow-up.
There is no visible change.